Skip to content

Infer the PR from the checkout, and render the queue as one status line - #46

Merged
kristofferR merged 2 commits into
mainfrom
feat/infer-target-and-status-line
Jul 26, 2026
Merged

Infer the PR from the checkout, and render the queue as one status line#46
kristofferR merged 2 commits into
mainfrom
feat/infer-target-and-status-line

Conversation

@kristofferR

Copy link
Copy Markdown
Owner

Two ergonomics items from the v3 roadmap's P6, both about work an agent currently does by hand.

crq next with no arguments

A bare crq next inside a checkout infers its own target: read the current branch, match a
configured remote to an owner/name slug, then ask GitHub which open pull request has that head
(head=owner:branch). If nothing matches, or more than one does, it says so rather than guessing.

The skill has told agents to run crq from inside the checkout ever since local_work landed —
local_work is only accurate there. This makes standing in the right place pay for itself instead of
still requiring a repo and a number the agent is already inside of.

Applies to every command that takes a target, via one shared target() helper.

crq status --line

One line, for a status bar:

crq 🔬 #41 reviewing · 2 queued

It reports only what crq can actually know. Precedence is stranded > blocked > reviewing > idle, and
next #N appears only when the queue genuinely knows who is next — the same restraint as the
dashboard ordering: past the front, order is not knowable, because slot release comes from an
acknowledgement, not from pacing.

This is the countdown surface the roadmap moves heartbeats onto: a chat that wants to answer
"still going?" reads a line instead of spending a turn on crq doctor.

Also

crq status now rejects a positional argument. crq status 41 previously ignored it and printed
global status, which reads exactly like a report on PR 41.

Verification

gofmt -l . clean, go vet ./... clean, go test ./... green across all six packages.

New tests pin the two things that would otherwise pass for the wrong reason:

  • The GitHub fake now honours the head query parameter. It previously returned every PR in the
    repository, so an inference asking for the wrong branch would still have satisfied a
    single-result assertion.
  • TestStatusLine asserts the output contains no newline (it renders into a bar) and that a
    stranded round excludes every lower-priority status, not merely that "stranded" appears.

Ref #42

Two things an agent had to work around by hand.

A bare `crq next` inside a checkout now infers its target: read the
branch, match a remote to a repository slug, and ask GitHub which open
pull request has that head. The skill has told agents to run crq from
inside the checkout since `local_work` landed; now that being there is
worth something, they no longer have to paste a repo and a number they
already stand in.

And `crq status --line` renders the queue as a single line for a status
bar, so "still going?" has an answer that costs no turn. It reports only
what crq can know: stranded outranks blocked outranks reviewing, and
`next #N` appears only when the queue actually knows who is next.

`crq status` now rejects a positional argument instead of ignoring it —
`crq status 41` looked like it reported on that PR.
@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@kristofferR, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 13 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 7016e6c8-938a-43f4-a8f3-078d6c6fe82f

📥 Commits

Reviewing files that changed from the base of the PR and between d6a47a7 and 5a3697b.

📒 Files selected for processing (10)
  • cmd/crq/main.go
  • internal/crq/service.go
  • internal/crq/service_test.go
  • internal/crq/state.go
  • internal/crq/target.go
  • internal/crq/target_test.go
  • internal/state/dashboard_test.go
  • internal/state/statusline.go
  • llms.txt
  • skills/coderabbit-queue/SKILL.md
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/infer-target-and-status-line

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@kristofferR

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@kristofferR

Copy link
Copy Markdown
Owner Author

@codex review

@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ad7a9b2d58

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/crq/target.go Outdated
Comment thread internal/state/statusline.go Outdated
Comment thread internal/state/statusline.go Outdated
Comment thread cmd/crq/main.go
Four review findings on this branch, all correct.

Inference reached only next and wait, while the PR claimed every command
that takes a target. feedback, loop, cancel and debug enqueue now route
through the same helper, so a bare call works wherever a target is taken.

Fork checkouts could not be inferred at all. Taking the first remote and
its own owner asks /repos/me/app/pulls?head=me:branch, but the pull
request is filed against upstream — so the one case where carrying the
arguments by hand is most annoying reported that no PR exists. Inference
now considers every GitHub remote as a base and every remote owner as a
head. A single-remote checkout still costs exactly one request.

That makes a remote slug an API lookup rather than a comparison, so it
now requires a GitHub remote: repoSlugFromRemote is deliberately loose
for matching, where a wrong guess merely fails to match, and would have
turned /home/me/code/app into a request for code/app.

The status line could say "blocked" and then name the next PR in the
same breath — but a quota-free round stays actionable precisely because
the account window has no authority over it. Ready work now outranks the
block. It could also point past a stranded reservation, which reads as
though the queue is moving; the earlier precedence test only proved that
case with an empty queue behind it.
@kristofferR

Copy link
Copy Markdown
Owner Author

@codex review

@kristofferR

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@kristofferR
kristofferR merged commit b730ab5 into main Jul 26, 2026
2 checks passed
@kristofferR
kristofferR deleted the feat/infer-target-and-status-line branch July 26, 2026 16:18

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5a3697b629

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +40 to +41
default:
parts = append(parts, "🟢 ready")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid labeling delayed queues as ready

When the front round is awaiting a future RetryAt or the minimum-fire interval, Queue is nonempty but sets ReadyAt/Why, making ready false. If there is no account block or in-flight round, this default still renders crq 🟢 ready · 1 queued, even though nothing can fire yet. Add a separate non-ready queued state, ideally showing the applicable wait or countdown.

Useful? React with 👍 / 👎.

Comment thread internal/crq/target.go
// against a repo crq already knows, where a wrong guess simply fails to
// match. Here the slug becomes an API lookup, so a local path like
// /home/me/code/app must not turn into a request for code/app.
if !strings.Contains(strings.ToLower(fields[1]), "github.com") {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Validate the remote host before inferring a repository

When a non-GitHub remote merely contains github.com in its path—for example /home/me/src/github.com/owner/repo.git or https://gitlab.example/github.com/owner/repo.git—this substring check accepts it and repoSlugFromRemote turns it into owner/repo. If that GitHub repository has an open PR for the same branch, a bare command can silently operate on the wrong PR. Parse and validate the actual host while preserving deliberately supported SSH host aliases.

Useful? React with 👍 / 👎.

Comment thread internal/crq/target.go
Comment on lines +59 to +61
if err != nil {
return "", 0, err
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Skip nonexistent candidate remotes during inference

When a checkout has a stale, deleted, or inaccessible secondary GitHub remote, its ListPulls lookup returns 404 and this immediately aborts inference—even if an earlier valid remote already produced the unique PR match. Since the Cartesian search treats every remote as only a candidate, a not-found candidate should be skipped while authentication, throttling, and other request failures should still be returned.

Useful? React with 👍 / 👎.

Comment thread cmd/crq/main.go
Comment on lines +348 to +350
crq next [<repo> <pr>] [--wait] emit the single next action as JSON (--wait blocks)
omit the target inside a checkout: crq reads the
remote and branch to find the pull request

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3 Badge Update the authoritative CLI docs for the new forms

The runtime now accepts inferred targets, but the command-specific help for next, wait, loop, feedback, and cancel still prints mandatory <repo> <pr> forms, the general usage block still shows wait as mandatory, and the README command contract remains unchanged (including omitting status --line). This leaves the repository's designated contract and usage surfaces contradicting the new CLI, so update them alongside these new optional forms.

AGENTS.md reference: AGENTS.md:L5-L6

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant